Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#25: implement tool commandlet for intellij #297

Open
wants to merge 62 commits into
base: main
Choose a base branch
from

Conversation

ndemirca
Copy link
Contributor

@ndemirca ndemirca commented Apr 17, 2024

Closes #25

@ndemirca ndemirca marked this pull request as draft April 17, 2024 09:41
@ndemirca ndemirca marked this pull request as ready for review April 17, 2024 11:46
@ndemirca ndemirca marked this pull request as draft April 17, 2024 14:38
Copy link
Contributor

@salimbouch salimbouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me 👍

@coveralls
Copy link
Collaborator

coveralls commented Apr 23, 2024

Pull Request Test Coverage Report for Build 9764854954

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 22 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.7%) to 60.875%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/intellij/Intellij.java 3 87.5%
com/devonfw/tools/ide/io/FileAccess.java 4 63.64%
com/devonfw/tools/ide/io/FileAccessImpl.java 15 55.08%
Totals Coverage Status
Change from base Build 9761010934: 0.7%
Covered Lines: 5064
Relevant Lines: 8008

💛 - Coveralls

@ndemirca ndemirca marked this pull request as ready for review April 23, 2024 11:55
@ndemirca ndemirca marked this pull request as draft April 23, 2024 15:51
Copy link
Contributor

@salimbouch salimbouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me 👍

@ndemirca ndemirca marked this pull request as ready for review May 8, 2024 12:27
@ndemirca ndemirca requested a review from hohwille May 17, 2024 08:47
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndemirca Thanks for your improvements and all the great work in this PR. 👍
However, we still have some last mile to go to complete this story.
See my review comments for details.

.gitattributes Outdated Show resolved Hide resolved
} else if (this.context.getSystemInfo().isLinux()) {
return toolBinPath.resolve(IDEA_BASH_SCRIPT).toString();
} else {
return getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA).toString();
Copy link
Member

@hohwille hohwille Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is still wrong as we discussed in our meeting.
I already merged the PR #359 and resolved the conflicts into this PR.
If we did everything correct there is no such thing anymore than IntelliJ IDEA CA.app inside the software folder.
Also please be aware the different editions of intelliJ will have a different *.app name so your code would never work with the ultimate edition used by many projects (CE stands for Community Edition).
I hope it was already clarified meanwhile why we need the generic MacOS workaround and avoid such ugly OS-switches here and handling of MacOS apps in individual commandlets.
Ideally like in devonfw-ide after installation we can just call idea on any plattform to launch IntelliJ.
This PR therefore still needs some reworking...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a very simple workaround for mac ultimate and community/intellij edition.
The dmg extractor still keeps the IntelliJ IDEA CE.app/Contents/... in the software folder, so this way should suffice for now. For another method to ideally call it with idea on each platform, we need to do some more research and discussions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For further improvements I've added an issue: #440

Comment on lines 73 to 75
if (this.context.getSystemInfo().isMac()) {
setMacOsFilePermissions(getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described above.


if (Files.exists(binaryFile)) {
String permissionStr = FileAccessImpl.generatePermissionString(493);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems I missed to discuss on this API.
IMHO this is very bad design:

  • numeric file permissions must always be given in octal notation or nobody can understand what 493 actually is. If you write it octal as 0755 at least some bash/unix experienced user will understand what this.
  • We should avoid direct usage of FileAccessImpl in commandlets. That is why we have FileAccess interface.
  • Why do we provide a method in FileAccessImpl that converts a number to a String and then we again convert the String to a Set of PosixFilePermissions in order to then natively set this via Files.setPosixFilePermissions? The idea of FileAccess is to create a higher level API and abstraction to such lower-level Java NIO operations and make our live easier. So if we believe that using numeric (octal) notation is the most readable way why dont we create a method in FileAccess to set file permissions to a given file with a given numeric value? However, it may be even simpler and more readable to simply define constants for the combinations that we need like this:
/** {@link PosixFilePermission}s for "rwxr-xr-x" or 0755. */
public static Set<PosixFilePermission> RWX_RX_RX = Set.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_EXECUTE);
  • My real suggestion would rather be to add a method FileAccess.makeExecutable(Path) that will simply implement what chmod a+x «path» will do and could also be implemented to work on Windows (see also here).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented your suggestions now.

Comment on lines 87 to 88
} finally {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to add any value and is IMHO only causing confusion.

Suggested change
} finally {
return;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted.

@Override
public void installPlugin(PluginDescriptor plugin) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not implemented so this PR does not entirely close #25. If you do something like this on purpose, then create a new issue for IntelliJ plugin support and leave a comment here like TODO https://github.com/devonfw/IDEasy/issues/«id». Otherwise we still end up in the same situation that we have currently that some comandlets seem to be present but are incomplete and if we have no issue about the problem, we might forget about it and currently merging this PR would automatically close #25.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted with new issue.

…llij

# Conflicts:
#	cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
#	cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java
…thub.com:ndemirca/IDEasy into feature/25-Implement-ToolCommandlet-for-Intellij
added new makeExecutable method to FileAccess
added new RWX_RX_RX constant to FileAccess
replaced complicated sert of execute permissions in Intellij with makeExecutable method
added TODO for the implementation of plugin installation
applid reformat to FileAccess
@hohwille hohwille added this to the release:2024.07.002 milestone Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Implement ToolCommandlet for Intellij
5 participants